//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    internal class TableStyleList : IOfficeXmlSerializable
    {
        private const string xmlName = "tblStyleLst";
        private Guid _def;
        private readonly List<TableStyle> _tblStyle = new List<TableStyle>();

        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read(xmlName))
            {
                _def = new Guid(c.GetString("def"));
                _tblStyle.AddRange(c.ReadOptionalWhile<TableStyle>("tblStyle"));
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write(xmlName))
            {
                c.SetString("def", "{"+_def+"}");
                c.WriteElements(_tblStyle);
            }
        }

        #endregion
    }
}
